unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TSpecialCol=class(TObject)
  public
    Index:Integer;
    StaValue:Double;
    EndValue:Double;

  end;
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    FList:TList;
  public
    procedure Initialize;
    function  GetIndex(AValue:Double):Integer;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

function TForm1.GetIndex(AValue: Double): Integer;
var
  I:Integer;
  ASpeCol:TSpecialCol;
begin
  for I:=0 to FList.Count-1 do
  begin
    ASpeCol:=TSpecialCol(FList.Items[I]);

    if (AValue <= ASpeCol.EndValue) and (AValue >= ASpeCol.StaValue) then           // and (AValue < ASpeCol.EndValue)
    begin
      Result:=ASpeCol.Index;
      ShowMessage(IntToStr(ASpeCol.Index));
    end;
  end;
end;

procedure TForm1.Initialize;
var
  ArrSpeCol:array of TSpecialCol;
begin
  if FList<>nil then FreeAndNil(FList);

  FList:=TList.Create;

  SetLength(ArrSpeCol,3);

  ArrSpeCol[0]:=TSpecialCol.Create;
  
  ArrSpeCol[0].Index:=1;
  ArrSpeCol[0].StaValue:=500;
  ArrSpeCol[0].EndValue:=1000;
  FList.Add(ArrSpeCol[0]);

  ArrSpeCol[1]:=TSpecialCol.Create;
  ArrSpeCol[1].Index:=2;
  ArrSpeCol[1].StaValue:=1000;
  ArrSpeCol[1].EndValue:=2000;

  FList.Add(ArrSpeCol[1]);

  ArrSpeCol[2]:=TSpecialCol.Create;
  ArrSpeCol[2].Index:=3;
  ArrSpeCol[2].StaValue:=2000;
  ArrSpeCol[2].EndValue:=2500;
  FList.Add(ArrSpeCol[2]);



  GetIndex(1002);


end;

procedure TForm1.FormShow(Sender: TObject);
begin
  ShowMessage('True');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  initialize;
end;

end.
